package com.youku.plugins.commonui.view.noticeCard
{
   import flash.display.Sprite;
   import flash.display.Shape;
   import com.youku.utils.AssetUtil;
   import flash.events.Event;
   import com.youku.utils.OpenWindow;
   
   public class ErrorChangeBrowserCard extends BaseNoticeCard
   {
      
      public function ErrorChangeBrowserCard() {
         super();
         this.init();
      }
      
      private var _infowidth:Number;
      
      private var _infoheight:Number;
      
      private var _content:Sprite;
      
      private var _info:Sprite;
      
      private var _back:Shape;
      
      override protected function init() : void {
         super.init();
         this._back = new Shape();
         this._content = new Sprite();
         this._info = AssetUtil.getAsset("AD_changeInfo") as Sprite;
         this._infowidth = this._info.width;
         this._infoheight = this._info.height;
         this.addChild(this._back);
         this.addChild(this._content);
         this._content.addChild(this._info);
         this.addEvents();
      }
      
      private function addEvents() : void {
         this._info.addEventListener("onPressLink",this.onLinkClick);
         this._info.addEventListener("onPressLink2",this.onLink2Click);
      }
      
      private function onLinkClick(param1:Event) : void {
         OpenWindow.openURL("http://www.youku.com/service/feed/");
      }
      
      private function onLink2Click(param1:Event) : void {
         OpenWindow.openURL("http://vip.youku.com/");
      }
      
      override protected function updateLayout() : void {
         super.updateLayout();
         this._content.x = int((_width - this._infowidth * this._content.scaleX) / 2);
         this._content.y = int((_height - this._infoheight * this._content.scaleY) / 2);
         this._back.x = this._back.y = 0;
      }
      
      override public function setSize(param1:Number, param2:Number) : void {
         super.setSize(param1,param2);
         var _loc3_:Number = 1;
         if(this._infowidth / this._infoheight > param1 / param2)
         {
            if(this._infowidth > param1)
            {
               _loc3_ = param1 / this._infowidth;
            }
         }
         else if(this._infoheight > param2)
         {
            _loc3_ = param2 / this._infoheight;
         }
         
         this._content.scaleX = this._content.scaleY = _loc3_;
         this._back.graphics.clear();
         this._back.graphics.beginFill(0);
         this._back.graphics.drawRect(0,0,param1,param2);
         this._back.graphics.endFill();
         this.updateLayout();
      }
   }
}
